package com.tanhua.common.utils;

import com.tanhua.common.pojo.User;

/**
 * @Author 王加鑫
 * @Date 2021/09/04 21:46
 * @Since JDK 1.8
 */
public class UserThreadLocal {

    private static final ThreadLocal<User> LOCAL = new ThreadLocal<>();

    private UserThreadLocal(){

    }

    /**
     * 将对象放入到ThreadLocal
     */
    public static void set(User user){
        LOCAL.set(user);
    }

    /**
     * 返回当前线程中的user对象
     */
    public static User get(){
        return LOCAL.get();
    }

    /**
     * 删除当前线程中的user对象
     */
    public static void remove(){
        LOCAL.remove();
    }

}
